<template>
  <div class="app-container org">
    <!-- 左侧区域 -->
    <el-card style="width: 100%">
      <el-tabs v-model="activityName" class="demo-tabs">
        <el-tab-pane label="未完成" name="first">
          <isReviewed
            v-if="activityName == 'first'"
            @archiveFileId="archiveFileId"
            :archiveStatus="1"
            ref="isReviewedRef"
          />
        </el-tab-pane>
        <el-tab-pane label="已完成" name="second">
          <isReviewed
            v-if="activityName == 'second'"
            ref="isReviewedRef"
            :archiveStatus="2"
            @archiveFileId2="archiveFileId2"
          />
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script setup name="ProjectArchive">
import isReviewed from "./components/isReviewed";
import axios from "axios";
import { getToken } from "@/utils/auth";
import { blobValidate } from "@/utils/ruoyi";
const { proxy } = getCurrentInstance();

const router = useRouter();
const form = ref({});
const isReviewedRef = ref(null);

const activityName = ref("first");
async function archiveFileId(row) {
  // router.push({
  //   path: "/archive/pafView",
  //   query: { archiveFileId: val},
  // });
  proxy.$modal.loading("正在归档，请稍候...");
  proxy.$download.ossFileByte(row.bucketName, row.fileName).then((data) => {
    const blob = new Blob([data]);
      const file = new File([blob], "document.pdf", {
        type: "application/pdf",
      });
      const url = URL.createObjectURL(file);
      proxy.$modal.closeLoading();
      window.open(url);
  }).catch(res => {
    proxy.$modal.closeLoading();
  });
}

function archiveFileId2(val) {
  form.value.archiveFileId = val;
}

onMounted(() => {
  nextTick(() => {
    isReviewedRef.value?.getTableHeight();
  });
});
onUpdated(() => {
  isReviewedRef.value?.getTableHeight();
});
</script>

<style></style>
